package com.bjsxt.service.impl;

import com.bjsxt.commons.pojo.BaizhanResult;
import com.bjsxt.mapper.TbItemDescMapper;
import com.bjsxt.pojo.TbItemDesc;
import com.bjsxt.service.ItemDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author coder_z
 * @date 2023/2/9
 **/
@Service
public class ItemDescServiceImpl implements ItemDescService {
    @Autowired
    private TbItemDescMapper tbItemDescMapper;
    /**
     * 商品描述信息新增
     * @param desc
     * @return
     */
    @Transactional
    @Override
    public BaizhanResult insert(TbItemDesc desc) {
         int index=tbItemDescMapper.insert(desc);
         if(index==1){
             return BaizhanResult.ok();
         }
         return BaizhanResult.error("服务器端消息-新增失败");
    }
    /**
     * 根据id查询商品描述信息
     * @param id
     * @return
     */
    @Override
    public BaizhanResult selectById(long id) {
        TbItemDesc tbItemDesc = tbItemDescMapper.selectById(id);
        if(tbItemDesc!=null){
            return BaizhanResult.ok(tbItemDesc);
        }
        return BaizhanResult.error("服务器端消息-没有查询到商品描述信息");
    }

    @Override
    public BaizhanResult updateById(TbItemDesc desc) {
        int index = tbItemDescMapper.updateById(desc);
        if(index==1){
            return BaizhanResult.ok();
        }
        return BaizhanResult.error("服务器端消息-修改商品描述信息失败");
    }
}
